package org.vineatoum.view.utils;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.swing.tree.DefaultMutableTreeNode;

import org.vineatoum.business.state.Benne;
import org.vineatoum.business.state.abstraction.VinAbstract;

public class TransferableVinAbstract implements Transferable {

	private static final DataFlavor nodeFlavor  = new DataFlavor( VinAbstract.class,
			   DataFlavor.javaJVMLocalObjectMimeType);
	private VinAbstract va;

	private ArrayList<DataFlavor> dataFlavors = new  ArrayList<DataFlavor>();
	
	private void addDataFlavor(Class<?> c)
	{
		dataFlavors.add(new DataFlavor( c,
				   DataFlavor.javaJVMLocalObjectMimeType));
	}
	public TransferableVinAbstract(VinAbstract data) {
		va = data;
		dataFlavors.add(nodeFlavor);
		addDataFlavor(va.getClass());
	
	}

	@Override
	public Object getTransferData(DataFlavor arg0)
			throws UnsupportedFlavorException, IOException {
		// TODO Auto-generated method stub
		return va;
	}

	@Override
	public DataFlavor[] getTransferDataFlavors() {
		// TODO Auto-generated method stub
		DataFlavor temp[] = {};
		return  dataFlavors.toArray(temp);
	}
		
	@Override
	public boolean isDataFlavorSupported(DataFlavor arg0) {
		// TODO Auto-generated method stub
		return dataFlavors.contains(arg0);
	}
	/**
	 * @return the nodeflavor
	 */
	public static DataFlavor getNodeflavor() {
		return nodeFlavor;
	}
	
}
